import { RequestServerClass } from '@/util/request';
import qs from 'qs';

export class BaseServer {
  public rService: any;

  constructor(opt: any, axiosFilterFn?: any) {
    this.rService = new RequestServerClass(opt);
    if (axiosFilterFn) {
      axiosFilterFn.call(this, this.rService.serverObj);
    }
  }

  // get请求
  public getGetData(opts: any) {
    const url: string = '';
    return this.rService.serverObj.get(url + '?' + qs.stringify(opts));
  }
  // post请求
  public getPostData(opts: any) {
    const url: string = '';
    return this.rService.serverObj.post(url, {});
  }
  // post请求 下载
  public PostDownloadFile(opts: any) {
    const url: string = '';
    const type: any = {
      responseType: 'blob', // 服务器返回的数据类型
    };
    return this.rService.serverObj.post(url, opts, type);
  }
}
